package com.qf.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.homeproject.R;

public class MessageAdapter extends BaseAdapter
{

	final private Context context;
	private List<Map<String, Object>> listViewDatas = new ArrayList<Map<String, Object>>();
	private ImageView img;
	private TextView title;
	private TextView info;

	public MessageAdapter(Context context,
			List<Map<String, Object>> listViewDatas)
	{
		this.context = context;
		this.listViewDatas = listViewDatas;
	}

	@Override
	public int getCount()
	{
		// TODO Auto-generated method stub
		return listViewDatas.size();

	}

	@Override
	public Object getItem(int position)
	{
		// TODO Auto-generated method stub
		return listViewDatas.get(position);
	}

	@Override
	public long getItemId(int position)
	{
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		View view = LayoutInflater.from(context).inflate(
				R.layout.item_listview_shouye, null);
		img = (ImageView) view.findViewById(R.id.item_lview_shouye_ImgId);
		title = (TextView) view.findViewById(R.id.item_lview_shouye_titleId);
		info = (TextView) view.findViewById(R.id.item_lview_shouye_InfoId);
		img.setImageDrawable((Drawable) listViewDatas.get(position).get("img"));
		title.setText(listViewDatas.get(position).get("title").toString());
		info.setText(listViewDatas.get(position).get("info").toString());
		return view;
	}

}
